import { defineStore } from 'pinia'

export const useConfigStore = defineStore('config', {
    state: () => ({
        loading: true,
        platform: "",
        openAtLogin: false,
        autoUpdater: true,
        showTray: true,
        locale: "zh",
        theme: "light",
    }),
    getters: {
    },
    actions: {
        set(data: any) {
            data = data || {}
            if (data.openAtLogin !== undefined) {
                this.openAtLogin = data.openAtLogin
            }
            if (data.autoUpdater !== undefined) {
                this.autoUpdater = data.autoUpdater
            }
            if (data.showTray !== undefined) {
                this.showTray = data.showTray
            }
            if (data.locale !== undefined) {
                this.locale = data.locale
            }
            if (data.theme !== undefined) {
                this.theme = data.theme
            }
            this.loading = false
        }
    },
})